public class Jump {
    // https://leetcode.cn/problems/jump-game-ii/
    class Solution {
        public int jump(int[] nums) {

            int ans = 0;
            int curIndex = 0;
            int nextIndex = 0;
            for(int i = 0 ; i < nums.length -1 ; i ++)
            {
                nextIndex = Math.max(nums[i] + i , nextIndex);
                if(curIndex == i)
                {
                    curIndex = nextIndex;
                    ans ++;
                }
            }
            return ans;
        }
    }
}
